import {VuexModule, Module, Mutation, Action, getModule} from 'vuex-module-decorators'
import store from '@/store/store'

export interface RobOrderState {
    robDialog: boolean
    robUserName: string
    robUserPhone: string
    robOrderContent: string
    robStoreContent: string
    robOrderInfo: any
    robId: any
}

@Module({dynamic: true, store, name: 'robOrder'})
class RobOrder extends VuexModule implements RobOrderState {
    public robDialog = false;
    public robUserName = "";
    public robId = "0";
    public robUserPhone = "";
    public robOrderContent = "";
    public robStoreContent = "";
    public userId = "";
    public robOrderInfo: any = {
        robOrderInfo: {
            phone: "",
            userAddress: "",
            userDetails: "",
        }
    };

    @Mutation
    private CHANGE_SETTING(payload: { key: string, value: any }) {
        const {key, value} = payload;
        if (Object.prototype.hasOwnProperty.call(this, key)) {
            (this as any)[key] = value
        }
    }

    @Action
    public ChangeSetting(payload: { key: string, value: any }) {
        this.CHANGE_SETTING(payload)
    }
}

export const RobOrderModule = getModule(RobOrder);
